package com.cy.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.common.pojo.JsonResult;
import com.cy.sys.pojo.SysRole;
import com.cy.sys.service.SysRoleService;

/**
 * 此类处理角色模块的所有请求与相应
 * @author private
 *
 */
@RestController
// /role/doFindPageObjects  ?  pageCurrent=1&pageSize=10&name=admin
@RequestMapping("/role/")
public class SysRoleController {
	@Autowired
	private SysRoleService sysRoleService;
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doFindPageObjects")
	public JsonResult doFindPageObjects(String name, Integer pageCurrent, Integer pageSize) {
		return new JsonResult(sysRoleService.doFindPageObjects(name, pageCurrent, pageSize));
	}
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doSaveObject")
	public JsonResult doSaveObject(SysRole sysRole,Integer... menuIds) {
		sysRoleService.doSaveObject(sysRole,menuIds);
		return new JsonResult("insert ok");
	}
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doFindObjectById")
	public JsonResult doFindObjectById(Integer id) {
		return new JsonResult(sysRoleService.doFindObjectById(id));
	}
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doUpdateObject")
	public JsonResult doUpdateObject(SysRole sysRole,Integer... menuIds) {
		sysRoleService.doUpdateObject(sysRole,menuIds);
		return new JsonResult("update ok");
	}
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doDeleteObject")
	public JsonResult doDeleteObject(Integer id) {
		sysRoleService.doDeleteObject(id);
		return new JsonResult("delete ok");
	}
	
	/** 此类负责处理分页显示角色信息 */
	@RequestMapping("doFindRoles")
	public JsonResult doFindRoles() {
		return new JsonResult(sysRoleService.doFindRoles());
	}
	
}
